/**
 * ClassName: UserServiceImpl
 * Package: org.example.service.impl
 * Description: 用户服务实现类-基于注解方式暴露服务
 *
 * @Author BCXJ
 * @Create 2025/10/6 02:15
 * @Version 1.0
 * @Since 1.0
 */
package org.example.service.impl;

import org.apache.dubbo.config.annotation.Service;
import org.example.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 用户服务实现类
 * 使用@Service注解暴露服务
 */
@Service(version = "1.0.0", timeout = 3000)
public class UserServiceImpl implements UserService {
    
    private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
    
    /**
     * 根据用户ID获取用户名
     * 
     * @param userId 用户ID
     * @return 用户名
     */
    @Override
    public String getUserName(Long userId) {
        logger.info("【UserService-注解方式】接收到请求: getUserName, userId={}", userId);
        
        // 模拟数据库查询
        String username = "User_" + userId;
        
        logger.info("【UserService-注解方式】返回结果: {}", username);
        return username;
    }
    
    /**
     * 用户注册
     * 
     * @param username 用户名
     * @param password 密码
     * @return 注册结果信息
     */
    @Override
    public String registerUser(String username, String password) {
        logger.info("【UserService-注解方式】接收到请求: registerUser, username={}", username);
        
        // 模拟用户注册逻辑
        String result = "用户 " + username + " 注册成功！";
        
        logger.info("【UserService-注解方式】返回结果: {}", result);
        return result;
    }
}

